using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using Telerik.WinControls;
using Lion.Reports;

namespace LionForms
{
    public partial class Report : Telerik.WinControls.UI.RadForm
    {
        private ReportType ReportType;
        private DateTime From;
        private DateTime To;
        private Report()
        {
            InitializeComponent();
        }
        public Report(ReportType ReportType, DateTime From, DateTime To)
            : this()
        {
            this.ReportType = ReportType;
            this.From = From;
            this.To = To;
        }

        private void ReportForm_Load(object sender, EventArgs e)
        {
            DataTable dataTable;
            string sql;
            switch (ReportType)
            {
                case ReportType.GeneralJournal:
                    sql = string.Format(@"RptGeneralJournal @from='{0}', @to='{1}'", From, To);
                    dataTable = Lion.DataHelper.GetDataTable(sql);
                    GeneralJournal report = new Lion.Reports.GeneralJournal(dataTable, From, To);
                    this.reportViewer.Report = report;
                    break;
                case ReportType.GeneralLedger:
                    sql =string.Format(@"RptGeneralJournal @from='{0}', @to='{1}'", From, To);
                    dataTable = Lion.DataHelper.GetDataTable(sql);
                    this.reportViewer.Report = new Lion.Reports.GeneralLedger(dataTable,From,To);
                    break;
                case ReportType.BalanceSheet:
                    sql = "RptBalanceSheet";
                    dataTable = Lion.DataHelper.GetDataTable(sql);
                    this.reportViewer.Report = new Lion.Reports.BalanceSheet(dataTable);
                    break;
            }
            this.reportViewer.RefreshReport();

        }
    }
}
